package com.baiyang.server.service.system.impl;



import com.baiyang.server.tools.DataTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baiyang.server.dao.system.MenuRoleDao;
import com.baiyang.server.model.system.MenuRole;
import com.baiyang.server.service.impl.BaseServiceImpl;
import com.baiyang.server.service.system.MenuRoleService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 
 * @author XVX
 * BY: @Primary 注解帮助生命@Autowired优先注入的实列
 */
@Service	
public class MenuRoleServiceImpl extends BaseServiceImpl<MenuRoleDao, MenuRole>implements MenuRoleService{
    @Autowired
    private MenuRoleDao menuRoleDao = null;
    @Override
    public List<String> selectListExParent(MenuRole menuRole) {
        return menuRoleDao.selectListExParent(menuRole);
    }

    @Override
    @Transactional
    public void DelAndInsertBatch(List<MenuRole> menuRoles, String roleId) {
        menuRoleDao.deleteByRoleId(roleId);
        if(!DataTool.isBlank(menuRoles)){
            menuRoles.forEach(e->{
                e.setId(DataTool.createUUID());
            });
            menuRoleDao.insertBatch(menuRoles);
        }
    }
}
